package com.rabbiter.market.controller.user.login;

import com.rabbiter.market.common.web.response.JsonResult;
import com.rabbiter.market.service.login.ILoginService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.Map;

@RestController
@Validated
@RequestMapping("/user")
public class LoginUserController {

    @Resource
    private ILoginService loginService;

    @PostMapping("/login")
    public JsonResult login(@NotEmpty(message = "账号不能为空") String username, @NotEmpty(message = "密码不能为空") String password) {
        Map<String, Object> map = loginService.login(username, password);
        return JsonResult.success(map);

    }
}
